﻿using Microsoft.AspNetCore.Authorization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HSGD.Extensions.Authorizations.Policys {
    public class CustomizePermissionRequirement : AuthorizationHandler<CustomizePermissionRequirement>, IAuthorizationRequirement {
        protected override async Task HandleRequirementAsync(AuthorizationHandlerContext context, CustomizePermissionRequirement requirement) {

            if (context.User.Claims.Count() > 0) {
                //foreach(var role in  requirement)
                context.Succeed(requirement);
            }
            else {
                context.Fail();
            }
            await Task.CompletedTask;
            return;
        }
    }
}
